package controller;

import annotation.RequestMapping;
import dto.Repair.RepairListResp;
import dto.RepairDetail.DetailDate;
import dto.RepairDetail.RepairDetailResp;
import dto.RepairListReq;
import entity.Repair;
import entity.ResultVO;
import service.RepairService;

import java.sql.SQLException;

/**
 * @author Kevin
 * @date 2020-12-29 20:04
 */
public class RepairController {

    private RepairService repairService;

    public RepairController() {
        this.repairService = new RepairService();
    }

    @RequestMapping(value = "/repair/list", method = "POST")
    public ResultVO repairList(RepairListReq req) {
        RepairListResp result = repairService.repairList(req);
        return ResultVO.success(result);
    }

    @RequestMapping(value = "/repair/{id}")
    public ResultVO repairDetail(Integer id) throws SQLException {
        RepairDetailResp result = repairService.repairDetail(id);
        return ResultVO.success(result);
    }

    @RequestMapping(value = "/repair", method = "POST")
    public ResultVO repairSave(Repair repair) {
        return ResultVO.success(repair);
    }

    @RequestMapping(value = "/repair", method = "PUT")
    public ResultVO repairUpdate(Repair repair) {
        return ResultVO.success(repair);
    }

    @RequestMapping(value = "/repair/{id}", method = "DELETE")
    public ResultVO repairDelete(Integer id) {
        return ResultVO.success(id);
    }

    @RequestMapping(value = "/repair/detail", method = "POST")
    public ResultVO repairDetailSave(DetailDate detailDate) {
        return ResultVO.success(detailDate);
    }

    @RequestMapping(value = "/repair/detail/{id}", method = "DELETE")
    public ResultVO repairDetailDelete(Integer id) {
        return ResultVO.success(id);
    }

}
